package com.wetao.testkotlin

class TestDelegating<T>: Collection<T> {
    private val innerList = arrayListOf<T>()

    override val size: Int
        get() = innerList.size


    override fun contains(element: T): Boolean = innerList.contains(element)

    override fun containsAll(elements: Collection<T>): Boolean = innerList.containsAll(elements)

    override fun isEmpty(): Boolean = innerList.isEmpty()

    override fun iterator(): Iterator<T>  = innerList.iterator()
}

//类委托by
class TestDelegating2<T>(val innerList: Collection<T> = arrayListOf()): Collection<T> by innerList {
    override val size: Int
        get() = innerList.size + 1
}

